#! /usr/bin/python

import math

def isPrime(n):
    if n == 2 or n == 3 or n == 5 or n == 7: return True
    if n%2 == 0 or n%3 == 0 or n == 1: return False
    for i in range(5, int(math.sqrt(n))+1, 6):
	if n%i == 0 or n%(i+2) == 0: return False
    return True

primes = [2]

for i in range(1, 10**5, 2):
    if isPrime(i): primes.append(i)

alln = [1]    
def caculateN(radical):
    power = 16
    l = []
    N = []
    
    if len(radical) == 1: return int(5/math.log10(radical[0]))

    product = 1
    for r in radical:
        product *= r

    if len(radical) == 2: 	
	for i in range(1, power): 
	    for j in range(1, power):
		p = radical[0]**i * radical[1]**j
		if p > 10**5: break
		N.append(p)

    if len(radical) == 3:
	for i in range(1, power): 
	    for j in range(1, power):
		for k in range(1, power):
		    p = radical[0]**i * radical[1]**j * radical[2]**k
		    if p > 10**5: break
		    N.append(p)

    if len(radical) == 4:
	for i in range(1, power): 
	    for j in range(1, power):
		for k in range(1, power):
		    for m in range(1, power/2):
		        p = radical[0]**i * radical[1]**j * radical[2]**k * radical[3]**m
		        if p > 10**5: break
		        N.append(p)

    if len(radical) == 5:
	for i in range(1, power): 
	    for j in range(1, power):
		for k in range(1, power):
		    for m in range(1, power/2):
		        for n in range(1, power/2):
		            p = radical[0]**i * radical[1]**j * radical[2]**k * radical[3]**m * radical[4]**n
		            if p > 10**5: break
		            N.append(p)

    if len(radical) == 6:
	for i in range(1, power/2): 
	    for j in range(1, power/2):
		  p = radical[0]**i * radical[1]**j * radical[2] * radical[3] * radical[4] * radical[5]
		  if p > 10**5: break
		  N.append(p)
    N.sort()
    alln.extend(N)
    print N
    return len(N)

caculateN([3, 11, 59])










